package com.example.myapplication.tools;

import android.content.Context;
import android.content.Intent;
import android.os.CountDownTimer;
import android.util.Log;
import android.widget.TextView;

import com.example.myapplication.ui.Logo;

public class BackBanner extends CountDownTimer {

    Context context;
    TextView tv;

    /**
     * 参数 millisInFuture       倒计时总时间（如60S，120s等）
     * 参数 countDownInterval    渐变时间（每次倒计1s）
     */
    public BackBanner(long millisInFuture, long countDownInterval
            , Context context) {
        super(millisInFuture, countDownInterval);
        this.context = context;
    }

    public void setView(TextView tv){
        this.tv = tv;
    }

    @Override
    public void onTick(long l) {
        int time = (int)l/1000;
        if(tv != null){
            tv.setText(l/1000 + "s");
        }
    }

    @Override
    public void onFinish() {
        Intent it = new Intent(context, Logo.class);
        context.startActivity(it);
    }
}
